package cn.com.open.itembank.service;

import cn.com.open.itembank.dto.*;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * Created by lucky on 2017/10/9.
 */
@FeignClient(name = "item-item-service")
public interface ItemBankQuestionRemoteService {

    /**
     * 获取指定题库下指定试题全部信息.
     *
     * @param itemBankId 题库id
     * @param questionId 试题id
     * @return 试题模型 full item
     */
    @GetMapping(value = "/itembank/{id}/question/{questionId}")
    ReturnModel getFullItem(@PathVariable("id") String itemBankId, @PathVariable(value = "questionId") String questionId);

    /**
     * 获取指定题库下指定试题答案信息.
     *
     * @param itemBankId 题库id
     * @param questionId 试题id
     * @return 试题答案模型 item answer
     */
    @GetMapping(value = "/itembank/{id}/question/{questionId}/answer")
    ReturnModel getItemAnswer(@PathVariable("id") String itemBankId, @PathVariable(value = "questionId") String questionId);

    /**
     * 获取指定题库下指定试题不含答案的信息.
     *
     * @param itemBankId 题库id
     * @param questionId 试题id
     * @return 试题答案模型 item without answer
     */
    @GetMapping(value = "/itembank/{id}/question/{questionId}/withoutanswer")
    ReturnModel getItemWithoutAnswer(@PathVariable("id") String itemBankId, @PathVariable(value = "questionId") String questionId);

    /**
     * 随机获取指定题库指定题型指定数量的试题集合.
     * 历史接口：openapi/v3/ItemBank/{cid}/type/{tid}/GetRandomQuestions
     *
     * @param itemBankId     题库id
     * @param questionTypeId 题型id
     * @param cnt            获取数量
     * @return 试题id集合 random questions by item bank id and q type
     */
    @GetMapping(value = "/itembank/{id}/questiontype/{questionTypeId}/question/random")
    ReturnModel getRandomQuestionsByItemBankIdAndQType(@PathVariable(value = "id") String itemBankId,
                                                       @PathVariable(value = "questionTypeId") String questionTypeId,
                                                       @RequestParam(value = "cnt") int cnt);

    /**
     * 根据题库id获取指定题库下试题按照题型，难度，应用类别的数量统计列表.
     * 历史接口：openapi/v3/ItemBank/{itemBankId}/GetQuestionCount
     *
     * @param itemBankId 题库id
     * @return 数量统计列表 question stat by item bank id
     */
    @GetMapping(value = "/itembank/{id}/question/stat/oes")
    ReturnModel getQuestionStatByItemBankId(@PathVariable(value = "id") String itemBankId);

    /**
     * 根据题库id获取指定题库下试题按照应用类别的数量统计列表.
     * 历史接口：/openapi/v3/Course/{courseId}/Question/GetQuestionCountByQuestionType
     *
     * @param itemBankId 题库id
     * @return 数量统计列表 question stat for category by item bank id
     */
    @GetMapping(value = "/itembank/{id}/question/category/stat")
    ReturnModel getQuestionStatForCategoryByItemBankId(@PathVariable(value = "id") String itemBankId);

    /**
     * 根据题库id获取指定题库下指定题型的试题按照给定的章节,应用类别统计的难中易三档题数列表.
     * 历史接口：/openapi/v3/ItemBank/{ItemBankId}/Question/ConditionCount
     * 撤销历史接口：/openapi/v3/Course/{CourseId}/Question/ConditionCountByCourseId
     *
     * @param itemBankId 题库id
     * @param cntModel   统计参数模型
     * @return 数量统计列表 question difficulty stat by item bank id
     */
    @PostMapping(value = "/itembank/{id}/question/difficulty/stat")
    ReturnModel getQuestionDifficultyStatByItemBankId(@PathVariable(value = "id") String itemBankId,
                                                      @RequestBody DifficultyCountModel cntModel);

    /**
     * 新增试题（以itembankid为准替代模型对应数值）.
     *
     * @param itemBankId    题库id
     * @param questionModel 试题录入模型
     * @param appKey        app key
     * @param source        来源：0，内部；1，外部
     * @return the return model
     */
    @PostMapping(value = "/itembank/{id}/question")
    ReturnModel addQuestion(@PathVariable(value = "id") String itemBankId, @RequestBody QuestionModel questionModel,
                            @RequestParam("appkey") String appKey, @RequestParam("source") int source);

    /**
     * 切换试题审核状态.
     *
     * @param itemBankId 题库id
     * @param questionId 试题id
     * @param appKey     appkey
     * @param isCheck    True，审核通过；False，取消审核
     * @return the return model
     */
    @PutMapping(value = "/itembank/{id}/question/{questionId}/check")
    ReturnModel updateCheckStatus(@PathVariable(value = "id") String itemBankId, @PathVariable(value = "questionId") String questionId,
                                  @RequestParam("appkey") String appKey, @RequestParam("isCheck") boolean isCheck);

    /**
     * 切换试题停启用状态.
     *
     * @param itemBankId 题库id
     * @param questionId 试题id
     * @param appKey     appkey
     * @return the return model
     */
    @PutMapping(value = "/itembank/{id}/question/{questionId}/status")
    ReturnModel updateStatus(@PathVariable(value = "id") String itemBankId, @PathVariable(value = "questionId") String questionId,
                             @RequestParam("appkey") String appKey);

    //region 临时删除试题

    /**
     * 临时删除试题
     *
     * @param itemBankId 题库id
     * @param questionId 试题id
     * @param appKey     appkey
     * @return the return model
     */
    @DeleteMapping(value = "/itembank/{id}/question/{questionId}")
    ReturnModel deleteQuestion(@PathVariable(value = "id") String itemBankId, @PathVariable(value = "questionId") String questionId,
                               @RequestParam("appkey") String appKey);

    //endregion

    //region 批量临时删除试题

    /**
     * 批量临时删除试题
     *
     * @param id     题库id
     * @param idList 试题id集合
     * @param appKey appkey
     * @return the return model
     */
    @PostMapping(value = "/itembank/{id}/question/batchdelete")
    ReturnModel deleteQuestionList(@PathVariable(value = "id") String id, @RequestBody IdentifierArray idList,
                                   @RequestParam("appkey") String appKey);

    //endregion

    //region 恢复试题

    /**
     * 恢复试题.
     *
     * @param id         题库id
     * @param questionId 试题id
     * @param appKey     appkey
     * @return the return model
     */
    @PutMapping(value = "/itembank/{id}/question/{questionId}/recover")
    ReturnModel recover(@PathVariable(value = "id") String id, @PathVariable(value = "questionId") String questionId,
                        @RequestParam("appkey") String appKey);
    //endregion

    //region 批量恢复试题

    /**
     * 批量恢复试题.
     *
     * @param id     题库id
     * @param idList the id list
     * @param appKey appkey
     * @return the return model
     */
    @PostMapping(value = "/itembank/{id}/question/batchrecover")
    ReturnModel recoverList(@PathVariable(value = "id") String id, @RequestParam("ids") String idList,
                            @RequestParam("appkey") String appKey);
    //endregion

    //region 彻底删除试题

    /**
     * 彻底删除试题.
     *
     * @param id         题库id
     * @param questionId 试题id
     * @param appKey     appkey
     * @return the return model
     */
    @DeleteMapping(value = "/itembank/{id}/question/{questionId}/remove")
    ReturnModel removeQuestion(@PathVariable(value = "id") String id, @PathVariable(value = "questionId") String questionId,
                               @RequestParam("appkey") String appKey);

    //endregion

    //region 批量彻底删除试题

    /**
     * 批量彻底删除试题.
     *
     * @param id     题库id
     * @param idList the id list
     * @param appKey appkey
     * @return the return model
     */
    @PostMapping(value = "/itembank/{id}/question/batchremove")
    ReturnModel removeQuestionList(@PathVariable(value = "id") String id, @RequestBody IdentifierArray idList,
                                   @RequestParam("appkey") String appKey);

    //endregion

    //region 获取试题列表

    /**
     * 试题列表.
     *
     * @param itemBankId     the item bank id
     * @param filterModelDto the filter model dto
     * @param isOuter        the is outer
     * @param isGetContent   the is get content
     * @return the return model
     */
    @PostMapping(value = "/itembank/{id}/question/getlist")
    ReturnModel getList(@PathVariable(value = "id") String itemBankId, @RequestBody FilterModelDto filterModelDto,
                        @RequestParam("isOuter") Boolean isOuter, @RequestParam("isGetContent") Boolean isGetContent);

    //endregion

    // region 获取回收站列表

    /**
     * 获取回收站列表
     *
     * @param id             题库id
     * @param filterModelDto 数据集合
     * @return rycle bin list
     */
    @PostMapping(value = "/itembank/{id}/question/recylebin")
    ReturnModel getRycleBinList(@PathVariable(value = "id") String id, @RequestBody FilterModelDto filterModelDto);

    /**
     * 试题状态批量修改
     *
     * @param id          题库ID
     * @param statusModel 更新状态对象
     * @param appkey      所属AppKey
     * @return return model
     */
    @PutMapping(value = "/itembank/{id}/question/status")
    ReturnModel batchUpdateStatus(@PathVariable(value = "id") String id, @RequestBody UpdateQuestionStatus statusModel,
                                  @RequestParam("appKey") String appkey);

    /**
     * 试题修改
     *
     * @param id            题库ID
     * @param questionid    试题ID
     * @param questionModel 试题模型
     * @param appkey        所属AppKey
     * @return return model
     */
    @PutMapping(value = "/itembank/{id}/question/{questionid}")
    ReturnModel updateQuestion(@PathVariable(value = "id") String id, @PathVariable(value = "questionid") String questionid,
                               @RequestBody QuestionModel questionModel, @RequestParam("appkey") String appkey);
    //endregion

    //region 导出试题

    /**
     * 导出试题.
     *
     * @param itemBankId     the item bank id
     * @param filterModelDto the filter model dto
     * @return the return model
     */
    @PostMapping(value = "/itembank/{id}/question/exportquestion")
    ReturnModel exportQuestion(@PathVariable(value = "id") String itemBankId, @RequestBody FilterModelDto filterModelDto);

    /**
     * 试题导入
     *
     * @param itemBankId  题库id
     * @param importModel the importModel
     * @return the return model
     */
    @RequestMapping(value = "/itembank/{itemBankId}/question/import", method = RequestMethod.POST)
    ReturnModel importQuestion(@PathVariable(value = "itemBankId") String itemBankId, @RequestBody ImportParameter importModel);

    /**
     * 试题导入(纯文本)
     * @param itemBankId
     * @param importModel
     * @return
     */
    @RequestMapping(value = "/itembank/{itemBankId}/question/importByText", method = RequestMethod.POST)
    ReturnModel importQuestionByText(@PathVariable(value = "itemBankId") String itemBankId, @RequestBody ImportParameter importModel);

    //endregion

    //region 获取试题模型

    /**
     * 获取试题模型.
     *
     * @param itemBankId 题库id
     * @return full item
     */
    @GetMapping(value = "/itembank/{id}/question/esr")
    ReturnModel getQuestionModel(@PathVariable("id") String itemBankId);

    //endregion
}
